﻿using MediatR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using wt.wine.Application.Common.Interfaces;
using wt.wine.Application.Common.Models;

namespace wt.wine.Application.OutWineCommand.Command
{
    /// <summary>
    /// 校验提交
    /// </summary>
    public class CalibrationSubmitCommand : IRequest<Json<string>>
    {
        public string device { get; set; }
        public int num { get; set; }
    }

    public class CalibrationSubmitCommandHandler : IRequestHandler<CalibrationSubmitCommand, Json<string>>
    {
        private readonly ICheckWineResponse _icheckwineResponse;
        public CalibrationSubmitCommandHandler(ICheckWineResponse icheckwineResponse)
        {
            _icheckwineResponse = icheckwineResponse;
        }
        public async Task<Json<string>> Handle(CalibrationSubmitCommand request, CancellationToken cancellationToken)
        {
            if (string.IsNullOrWhiteSpace(request.device))
            {
                return new Json<string>() { Status = 1003, Detail = "请选择需要校准的出酒编码" };
            }
            else
            {
                await _icheckwineResponse.CalibrationSubmit(request.device, request.num, cancellationToken);
                return new Json<string>() { Status = 1000, Detail = "校准命令已经发送" };
            }
        }
    }
}
